Imports System
Imports System.Runtime.InteropServices

Public Class CreateInternetShortcut
    <ComImport(), _
        Guid("CABB0DA0-DA57-11CF-9974-0020AFD79762"), _
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
    Private Interface IUniformResourceLocatorW
        Sub SetURL( _
                <MarshalAs(UnmanagedType.LPWStr)> ByVal _
                pcszURL As String, _
                ByVal dwInFlags As Int16)

        Sub GetURL( _
                <Out(), MarshalAs(UnmanagedType.LPWStr)> ByVal ppszURL As String)

        Sub InvokeCommand( _
                ByVal purlici As IntPtr)
    End Interface


    <ComImport(), Guid("FBF23B40-E3F0-101B-8488-00AA003E56F8")> _
    Private Class InternetShortcut
        Implements IUniformResourceLocatorW

        Public Sub GetURL(ByVal ppszURL As String) Implements IUniformResourceLocatorW.GetURL

        End Sub

        Public Sub InvokeCommand(ByVal purlici As System.IntPtr) Implements IUniformResourceLocatorW.InvokeCommand

        End Sub

        Public Sub SetURL(ByVal pcszURL As String, ByVal dwInFlags As Short) Implements IUniformResourceLocatorW.SetURL

        End Sub
    End Class

    Public Sub CreateShortcut( _
                    ByVal sFilePath As String, _
                    ByVal sURL As String)

        Dim oIS As New InternetShortcut
        Dim oPF As System.Runtime.InteropServices.ComTypes.IPersistFile = oIS

        oIS.SetURL(sURL, 0)
        oPF.Save(sFilePath & ".url", True)

        Marshal.ReleaseComObject(oPF)
    End Sub
End Class
